﻿@{
    ViewBag.Title = "餐馆首页";
}

<script src="~/Scripts/jquery.timeago.js"></script>

<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">餐馆首页</h1>
    </div>
</div>
<div class="row">
    <div class="col-lg-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <i class="fa fa-cutlery fa-fw"></i> 订单信息
                <div class="btn-group pull-right">
                    <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu slidedown">
                        <li>
                            <a href="#">
                                <i class="fa fa-refresh fa-fw"></i> 刷新订单
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fa fa-list-alt fa-fw"></i> 查看所有
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div id="order_list" class="list-group">
                    
                </div>
                <!-- /.list-group -->
            </div>
            <!-- /.panel-body -->
        </div>
    </div>

    <div class="col-lg-6">
        <div class="chat-panel panel panel-default">
            <div class="panel-heading">
                <i class="fa fa-bullhorn fa-fw"></i>
                供货商信息
                <div class="btn-group pull-right">
                    <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
                        <i class="fa fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu slidedown">
                        <li>
                            <a href="#">
                                <i class="fa fa-refresh fa-fw"></i> 刷新
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="fa fa-list-alt fa-fw"></i> 查看所有
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <marquee direction="up" behavior="scroll" scrollamount="66" scrolldelay="5000" loop="-1" width="100%" height="100%">
                    <ul class="chat">
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">李老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 12 分钟前
                                    </small>
                                </div>
                                <p>
                                    特级生鲜，联系电话 023-68686868
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/FA6F57/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">王老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 14 分钟前
                                    </small>
                                </div>
                                <p>
                                    深山野生香菇，联系电话 023-86899898
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">刘老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 14 分钟前
                                    </small>
                                </div>
                                <p>
                                    农家散养鸡，联系电话 023-87878787
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">李老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 12 分钟前
                                    </small>
                                </div>
                                <p>
                                    特级生鲜，联系电话 023-68686868
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/FA6F57/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">王老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 14 分钟前
                                    </small>
                                </div>
                                <p>
                                    深山野生香菇，联系电话 023-86899898
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">刘老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 14 分钟前
                                    </small>
                                </div>
                                <p>
                                    农家散养鸡，联系电话 023-87878787
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">李老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 12 分钟前
                                    </small>
                                </div>
                                <p>
                                    特级生鲜，联系电话 023-68686868
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/FA6F57/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">王老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 14 分钟前
                                    </small>
                                </div>
                                <p>
                                    深山野生香菇，联系电话 023-86899898
                                </p>
                            </div>
                        </li>
                        <li class="left clearfix">
                            <span class="chat-img pull-left">
                                <img src="http://placehold.it/50/55C1E7/fff" alt="User Avatar" class="img-circle" />
                            </span>
                            <div class="chat-body clearfix">
                                <div class="header">
                                    <strong class="primary-font">刘老师</strong>
                                    <small class="pull-right text-muted">
                                        <i class="fa fa-clock-o fa-fw"></i> 14 分钟前
                                    </small>
                                </div>
                                <p>
                                    农家散养鸡，联系电话 023-87878787
                                </p>
                            </div>
                        </li>
                    </ul>
                </marquee>
            </div>
            <!-- /.panel-body -->
        </div>
    </div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        getOrderList();
        setInterval(getOrderList, 10*1000);
    });

    function getOrderList()
    {
        $.ajax({
            method: "post",
            url: "/RRShop/Order/OrderList",
            data: { pageNo:1 ,pageCount:10, restaurant_Id: @ViewBag.Id}
        }).done(function (orders) {
            var orderListDiv=$("#order_list");
            orderListDiv.empty();
            for (var i = 0; i < orders.length; i++) {
                var order = orders[i];
                var itemHTML = "<a href='/RRShop/Order/Detail/" + order.Id + "?restaurant_id="+order.Restaurant_Id+"' class='list-group-item'>";
                itemHTML += "<i class='fa fa-mobile fa-fw'></i> " + order.OrderNo;
                itemHTML += "<span class='pull-right text-muted small'>";
                itemHTML += "<em>" + $.timeago(parseInt(order.OrderTime.slice(6))) + "</em>";
                itemHTML += "</span>";
                itemHTML += "</a>";
                $("#order_list").append(itemHTML);
            }

        }).fail(function( jqXHR, textStatus ) {
            console.log( "Request failed: " + textStatus );
        });
    }
</script>